package lightswitch.server.code.sqlhelper.statement.select;

import java.util.ArrayList;
import java.util.List;

import lightswitch.server.code.sqlhelper.expression.Column;
import lightswitch.server.code.util.StringHelper;

public class SelectItems {
	public List<Column> _columnList;

	public SelectItems() {

	}

	public SelectItems(String statement, From _from) {
		if (statement == "") {
			// throw exception
			return;
		}
		statement = StringHelper.NormalizeString(statement);
		_columnList = new ArrayList<Column>();
		statement = statement.substring("select ".length());
		statement = StringHelper.NormalizeString(statement);
		String[] items = statement.split(",");
		// int k = items.length;
		for (int i = 0; i < items.length; i++) {
			Column col = null;
				col = new Column(items[i], _from);
				_columnList.add(col);
			}

		

	}

	public String toString() {
		String t = " select ";
		t = t + " ";
		for (int i = 0; i < _columnList.size(); i++) {
			t = t + _columnList.get(i).toString() + " , ";
		}
		return t + "  ";
	}
}
